Setup
knitr::opts_chunk$set(echo = TRUE)
library(tidyverse)
library(R.utils)
library(wbCorr)
library(readxl)
library(kableExtra)
library(brms)
library(bayesplot)
top_directory <- file.path(
'C:', 'Users', 'kueng', 'OneDrive - Universität Zürich UZH',
'04 Papers', '02 T&T Control', 'Analysis', 'ACTIVITY', 'BRMS'
)
working_directory <- file.path(top_directory, 'SensitivityCovariates')
setwd(working_directory)
functions_directory <- file.path('C:', 'Users', 'kueng',
'OneDrive - Universität Zürich UZH',
'RFunctions')
source(file.path(functions_directory, 'ReportModels.R'))
source(file.path(functions_directory, 'PrettyTables.R'))
source(file.path(functions_directory, 'ReportMeasures.R'))
source(file.path(top_directory, 'Functions', 'PrepareData.R'))
## [1] 1116
# Set options for analysis
use_mi = FALSE
shutdown = FALSE
report_ordinal = FALSE
options(
dplyr.print_max = 100,
brms.backend = 'cmdstan',
brms.file_refit = ifelse(use_mi, 'never', 'on_change'),
error = function() beepr::beep(sound = 5)
)
df <- openxlsx::read.xlsx(file.path(working_directory, 'long.xlsx'))
df_original <- df
df_double <- prepare_data(df, use_mi = use_mi)[[1]]
Constructing scales Re-coding pusing reshaping data (4field)
centering data within and between
Modelling
# For indistinguishable Dyads
model_rows_fixed <- c(
'Intercept',
# '-- WITHIN PERSON MAIN EFFECTS --',
'persuasion_self_cw',
'persuasion_partner_cw',
'pressure_self_cw',
'pressure_partner_cw',
'pushing_self_cw',
'pushing_partner_cw',
'day',
'weartime_self_cw',
'support_self_cw',
'support_partner_cw',
'isWeekendWeekend',
'got_JITAI_selfJITAIreceived',
'skilled_supportDaysafterIntervention',
# '-- BETWEEN PERSON MAIN EFFECTS',
'persuasion_self_cb',
'persuasion_partner_cb',
'pressure_self_cb',
'pressure_partner_cb',
'pushing_self_cb',
'pushing_partner_cb',
'weartime_self_cb',
'studyGroupFirst3weeksinterventions',
'studyGrouplast3weeksinterventions'
)
model_rows_fixed_ordinal <- c(
model_rows_fixed[1],
'Intercept[1]',
'Intercept[2]',
'Intercept[3]',
'Intercept[4]',
'Intercept[5]',
model_rows_fixed[2:length(model_rows_fixed)]
)
model_rows_random <- c(
# '--------------',
# '-- RANDOM EFFECTS --',
'sd(Intercept)',
'sd(persuasion_self_cw)',
'sd(persuasion_partner_cw)',
'sd(pressure_self_cw)',
'sd(pressure_partner_cw)',
'sd(pushing_self_cw)',
'sd(pushing_partner_cw)',
# '-- CORRELATION STRUCTURE -- ',
'ar[1]',
'nu',
'shape',
'sderr',
'sigma'
)
model_rows_random_ordinal <- c(model_rows_random,'disc')
# For indistinguishable Dyads
model_rownames_fixed <- c(
'Intercept',
# '-- WITHIN PERSON MAIN EFFECTS --',
'Daily perceived persuasion target -> target',
'Daily perceived persuasion target -> agent',
'Daily perceived pressure target -> target',
'Daily perceived pressure target -> agent',
'Daily perceived pushing target -> target',
'Daily perceived pushing target -> agent',
'Day',
'Daily weartime',
'Daily perceived support target -> target',
'Daily perceived support target -> agent',
'Is a weekend',
'JITAI received',
'Days post skilled support intervention',
# '-- BETWEEN PERSON MAIN EFFECTS',
'Mean perceived persuasion target -> target',
'Mean Perceived persuasion target -> agent',
'Mean Perceived pressure target -> target',
'Mean Perceived pressure target -> agent',
'Mean Perceived pushing target -> target',
'Mean Perceived pushing target -> agent',
'Mean weartime',
'Difference study group 2',
'Difference study group 3'
)
model_rownames_fixed_ordinal <- c(
model_rownames_fixed[1],
'Intercept[1]',
'Intercept[2]',
'Intercept[3]',
'Intercept[4]',
'Intercept[5]',
model_rownames_fixed[2:length(model_rownames_fixed)]
)
model_rownames_random <- c(
# '--------------',
# '-- RANDOM EFFECTS --',
'sd(Intercept)',
'sd(Daily perceived persuasion target -> target)',
'sd(Daily perceived persuasion target -> agent)',
'sd(Daily perceived pressure target -> target)',
'sd(Daily perceived pressure target -> agent)',
'sd(Daily perceived pushing target -> target)',
'sd(Daily perceived pushing target -> agent)',
# '-- CORRELATION STRUCTURE -- ',
'ar[1]',
'nu',
'shape',
'sderr',
'sigma'
)
model_rownames_random_ordinal <- c(model_rownames_random,'disc')
rows_to_pack <- list(
"Within-Person Effects" = c(2,14),
"Between-Person Effects" = c(15,23),
"Random Effects" = c(24, 30),
"Additional Parameters" = c(31,35)
)
rows_to_pack_ordinal <- list(
"Intercepts" = c(1,6),
"Within-Person Effects" = c(2+5,14+5),
"Between-Person Effects" = c(15+5,23+5),
"Random Effects" = c(24+5, 30+5),
"Additional Parameters" = c(31+5,35+6)
)
Subjective MVPA
range(df_double$pa_sub, na.rm = T)
## [1] 0 720
hist(df_double$pa_sub, breaks = 100)

Modelling using the gaussian family fails. Due to the many zeros,
transformations won’t help estimating the models. We employ the negative
binomial family.
formula <- bf(
pa_sub ~
persuasion_self_cw + persuasion_partner_cw +
pressure_self_cw + pressure_partner_cw +
pushing_self_cw + pushing_partner_cw +
#barriers_self_cw +
support_self_cw + support_partner_cw +
#comf_self_cw + reas_self_cw +
isWeekend +
got_JITAI_self + skilled_support +
persuasion_self_cb + persuasion_partner_cb +
pressure_self_cb + pressure_partner_cb +
pushing_self_cb + pushing_partner_cb +
studyGroup +
day +
# Random effects
(persuasion_self_cw + persuasion_partner_cw +
pressure_self_cw + pressure_partner_cw +
pushing_self_cw + pushing_partner_cw | coupleID),
autocor = ~ ar(time = day, gr = coupleID:userID, p = 1)
)
prior1 <- c(
brms::set_prior("normal(0, 2.5)", class = "b"),
brms::set_prior("normal(0, 50)", class = "Intercept", lb = 0),
brms::set_prior("normal(0, 10)", class = "sd", group = "coupleID", lb = 0),
brms::set_prior("cauchy(0, 5)", class = "ar", lb = -1, ub = 1),
brms::set_prior("cauchy(0, 20)", class = "shape"),
brms::set_prior("cauchy(0, 10)", class='sderr')
)
#df_minimal <- df_double[, c("userID", all.vars(as.formula(formula)))]
pa_sub <- my_brm(
mi = use_mi,
imputed_data = implist,
formula = formula,
prior = prior1,
data = df_double,
family = brms::negbinomial(),
#control = list(adapt_delta = 0.99),
iter = 5000,
warmup = 2000,
chains = 4,
cores = 4,
seed = 7777,
file = file.path(working_directory, "models_cache", "pa_sub")
)
pp_check(pa_sub, type='hist')
## Using 10 posterior draws for ppc type 'hist' by default.
## `stat_bin()` using `bins = 30`. Pick better value with `binwidth`.

## Using 10 posterior draws for ppc type 'dens_overlay' by default.

##
## Computed from 12000 by 3732 log-likelihood matrix.
##
## Estimate SE
## elpd_loo -12014.0 177.5
## p_loo 35.8 3.6
## looic 24027.9 355.0
## ------
## MCSE of elpd_loo is NA.
## MCSE and ESS estimates assume MCMC draws (r_eff in [0.3, 1.8]).
##
## Pareto k diagnostic values:
## Count Pct. Min. ESS
## (-Inf, 0.7] (good) 3729 99.9% 707
## (0.7, 1] (bad) 3 0.1% <NA>
## (1, Inf) (very bad) 0 0.0% <NA>
## See help('pareto-k-diagnostic') for details.
plot(pa_sub, ask = FALSE)











summarize_brms(
pa_sub,
model_rows_fixed = model_rows_fixed,
model_rows_random = model_rows_random,
model_rownames_fixed = model_rownames_fixed,
model_rownames_random = model_rownames_random,
exponentiate = T) %>%
print_df(rows_to_pack = rows_to_pack)
|
|
IRR
|
l-95% CI
|
u-95% CI
|
Rhat
|
Bulk_ESS
|
Tail_ESS
|
|
Intercept
|
26.72*
|
17.32
|
41.49
|
1.001
|
2961.37
|
5150.66
|
|
Within-Person Effects
|
|
Daily perceived persuasion target -> target
|
1.05
|
0.94
|
1.18
|
1.000
|
10158.84
|
8909.68
|
|
Daily perceived persuasion target -> agent
|
1.04
|
0.93
|
1.17
|
1.000
|
10462.74
|
8729.24
|
|
Daily perceived pressure target -> target
|
0.94
|
0.71
|
1.28
|
1.000
|
8512.47
|
7411.87
|
|
Daily perceived pressure target -> agent
|
1.21
|
0.90
|
1.67
|
1.001
|
10442.05
|
7943.66
|
|
Daily perceived pushing target -> target
|
1.08
|
0.89
|
1.34
|
1.000
|
7154.35
|
7887.45
|
|
Daily perceived pushing target -> agent
|
1.06
|
0.90
|
1.27
|
1.000
|
10919.29
|
8856.10
|
|
Day
|
0.96
|
0.62
|
1.46
|
1.000
|
7618.10
|
7886.93
|
|
Daily weartime
|
NA
|
NA
|
NA
|
NA
|
NA
|
NA
|
|
Daily perceived support target -> target
|
1.25*
|
1.17
|
1.35
|
1.000
|
12188.25
|
8990.54
|
|
Daily perceived support target -> agent
|
1.21*
|
1.11
|
1.31
|
1.000
|
11562.51
|
8885.56
|
|
Is a weekend
|
1.22*
|
1.01
|
1.50
|
1.000
|
12722.15
|
8968.39
|
|
JITAI received
|
0.75*
|
0.58
|
0.97
|
1.001
|
12386.45
|
9447.34
|
|
Days post skilled support intervention
|
0.86
|
0.62
|
1.19
|
1.000
|
7682.55
|
8781.26
|
|
Between-Person Effects
|
|
Mean perceived persuasion target -> target
|
1.65
|
0.83
|
3.26
|
1.000
|
2587.15
|
5108.08
|
|
Mean Perceived persuasion target -> agent
|
1.17
|
0.60
|
2.32
|
1.001
|
2668.07
|
5088.51
|
|
Mean Perceived pressure target -> target
|
0.54
|
0.24
|
1.21
|
1.001
|
4074.67
|
6709.82
|
|
Mean Perceived pressure target -> agent
|
0.42*
|
0.19
|
0.95
|
1.000
|
3767.82
|
5661.90
|
|
Mean Perceived pushing target -> target
|
1.53
|
0.55
|
4.34
|
1.001
|
3525.25
|
5461.59
|
|
Mean Perceived pushing target -> agent
|
2.03
|
0.73
|
5.72
|
1.001
|
3660.47
|
5917.92
|
|
Mean weartime
|
NA
|
NA
|
NA
|
NA
|
NA
|
NA
|
|
Difference study group 2
|
0.80
|
0.46
|
1.37
|
1.001
|
2650.64
|
4306.40
|
|
Difference study group 3
|
1.12
|
0.64
|
1.94
|
1.002
|
2693.03
|
5043.26
|
|
Random Effects
|
|
sd(Intercept)
|
0.64
|
0.47
|
0.87
|
1.00
|
3450.52
|
6368.11
|
|
sd(Daily perceived persuasion target -> target)
|
0.07
|
0.00
|
0.21
|
1.00
|
4444.04
|
4171.61
|
|
sd(Daily perceived persuasion target -> agent)
|
0.07
|
0.00
|
0.18
|
1.00
|
5615.70
|
5271.33
|
|
sd(Daily perceived pressure target -> target)
|
0.17
|
0.01
|
0.53
|
1.00
|
6058.90
|
4675.72
|
|
sd(Daily perceived pressure target -> agent)
|
0.18
|
0.01
|
0.51
|
1.00
|
6012.32
|
4727.56
|
|
sd(Daily perceived pushing target -> target)
|
0.26
|
0.01
|
0.56
|
1.00
|
2781.12
|
2723.71
|
|
sd(Daily perceived pushing target -> agent)
|
0.11
|
0.00
|
0.30
|
1.00
|
5418.09
|
4813.41
|
|
Additional Parameters
|
|
ar[1]
|
0.03
|
-0.94
|
0.94
|
1.00
|
9013.24
|
6700.96
|
|
nu
|
NA
|
NA
|
NA
|
NA
|
NA
|
NA
|
|
shape
|
0.14
|
0.13
|
0.15
|
1.00
|
14505.42
|
9416.17
|
|
sderr
|
0.05
|
0.00
|
0.14
|
1.00
|
5181.12
|
4714.47
|
|
sigma
|
NA
|
NA
|
NA
|
NA
|
NA
|
NA
|
Device Based MVPA
range(df_double$pa_obj, na.rm = T)
## [1] 5.75 971.25
hist(df_double$pa_obj, breaks = 50)

df_double$pa_obj_log <- log(df_double$pa_obj)
hist(df_double$pa_obj_log, breaks = 50)

We tried negative binomial here as well for consistency, but the
model did not converge. Poisson also did not work. As we have no zeros
in this distribution, we log transform.
formula <- bf(
pa_obj_log ~
persuasion_self_cw + persuasion_partner_cw +
pressure_self_cw + pressure_partner_cw +
pushing_self_cw + pushing_partner_cw +
#barriers_self_cw +
support_self_cw + support_partner_cw +
#comf_self_cw + reas_self_cw +
isWeekend +
got_JITAI_self + skilled_support +
persuasion_self_cb + persuasion_partner_cb +
pressure_self_cb + pressure_partner_cb +
pushing_self_cb + pushing_partner_cb +
studyGroup +
day + weartime_self_cw + weartime_self_cb +
# Random effects
(persuasion_self_cw + persuasion_partner_cw +
pressure_self_cw + pressure_partner_cw +
pushing_self_cw + pushing_partner_cw | coupleID),
autocor = ~ ar(time = day, gr = coupleID:userID, p = 1)
)
prior1 <- c(
brms::set_prior("normal(0, 2.5)", class = "b"),
brms::set_prior("normal(0, 50)", class = "Intercept", lb = 0),
brms::set_prior("normal(0, 10)", class = "sd", group = "coupleID", lb = 0),
brms::set_prior("cauchy(0, 5)", class = "ar", lb = -1, ub = 1),
brms::set_prior("cauchy(0, 10)", class = "sigma", lb = 0)
)
#df_minimal <- df_double[, c("userID", all.vars(as.formula(formula)))]
pa_obj_log <- my_brm(
mi = use_mi,
imputed_data = implist,
formula = formula,
prior = prior1,
data = df_double,
family = gaussian(),
#control = list(adapt_delta = 0.99),
iter = 5000,
warmup = 2000,
chains = 4,
cores = 4,
seed = 7777,
file = file.path(working_directory, "models_cache", "pa_obj_log")
)
# plotting with the first imputed dataset.
pp_check(pa_obj_log, type='hist')
## Using 10 posterior draws for ppc type 'hist' by default.
## `stat_bin()` using `bins = 30`. Pick better value with `binwidth`.

## Using 10 posterior draws for ppc type 'dens_overlay' by default.

##
## Computed from 12000 by 3333 log-likelihood matrix.
##
## Estimate SE
## elpd_loo -2794.2 57.2
## p_loo 95.1 4.7
## looic 5588.4 114.4
## ------
## MCSE of elpd_loo is 0.1.
## MCSE and ESS estimates assume MCMC draws (r_eff in [0.3, 1.5]).
##
## All Pareto k estimates are good (k < 0.7).
## See help('pareto-k-diagnostic') for details.
plot(pa_obj_log, ask = FALSE)











summarize_brms(
pa_obj_log,
model_rows_fixed = model_rows_fixed,
model_rows_random = model_rows_random,
model_rownames_fixed = model_rownames_fixed,
model_rownames_random = model_rownames_random,
exponentiate = T) %>%
print_df(rows_to_pack = rows_to_pack)
|
|
exp(Est.)
|
l-95% CI
|
u-95% CI
|
Rhat
|
Bulk_ESS
|
Tail_ESS
|
|
Intercept
|
121.23*
|
100.82
|
145.60
|
1.000
|
4060.10
|
6293.50
|
|
Within-Person Effects
|
|
Daily perceived persuasion target -> target
|
1.01
|
0.98
|
1.04
|
1.000
|
11202.97
|
9404.56
|
|
Daily perceived persuasion target -> agent
|
1.00
|
0.97
|
1.03
|
1.001
|
13782.61
|
9627.01
|
|
Daily perceived pressure target -> target
|
0.95
|
0.89
|
1.01
|
1.000
|
14202.51
|
9489.78
|
|
Daily perceived pressure target -> agent
|
0.98
|
0.92
|
1.04
|
1.000
|
16982.92
|
8501.21
|
|
Daily perceived pushing target -> target
|
1.02
|
0.97
|
1.06
|
1.001
|
11888.59
|
8676.31
|
|
Daily perceived pushing target -> agent
|
1.02
|
0.98
|
1.06
|
1.000
|
16756.29
|
9284.65
|
|
Day
|
0.95
|
0.84
|
1.07
|
1.000
|
16821.49
|
8768.23
|
|
Daily weartime
|
1.00*
|
1.00
|
1.00
|
1.000
|
12148.79
|
8015.43
|
|
Daily perceived support target -> target
|
1.04*
|
1.02
|
1.05
|
1.001
|
19687.23
|
8578.81
|
|
Daily perceived support target -> agent
|
1.02*
|
1.00
|
1.04
|
1.000
|
20313.58
|
9388.57
|
|
Is a weekend
|
1.05*
|
1.01
|
1.10
|
1.001
|
19953.90
|
9028.63
|
|
JITAI received
|
0.93*
|
0.88
|
0.98
|
1.000
|
19481.13
|
9256.96
|
|
Days post skilled support intervention
|
1.03
|
0.94
|
1.12
|
1.000
|
15550.23
|
9456.64
|
|
Between-Person Effects
|
|
Mean perceived persuasion target -> target
|
1.07
|
0.80
|
1.46
|
1.001
|
3696.54
|
5491.87
|
|
Mean Perceived persuasion target -> agent
|
0.94
|
0.69
|
1.30
|
1.001
|
3670.41
|
5871.89
|
|
Mean Perceived pressure target -> target
|
1.02
|
0.73
|
1.42
|
1.001
|
5261.88
|
8442.33
|
|
Mean Perceived pressure target -> agent
|
0.98
|
0.72
|
1.34
|
1.002
|
4769.62
|
6557.83
|
|
Mean Perceived pushing target -> target
|
1.02
|
0.66
|
1.57
|
1.000
|
5582.80
|
7367.89
|
|
Mean Perceived pushing target -> agent
|
1.33
|
0.85
|
2.05
|
1.001
|
5447.49
|
7501.21
|
|
Mean weartime
|
1.00
|
1.00
|
1.00
|
1.000
|
15026.58
|
11061.83
|
|
Difference study group 2
|
0.89
|
0.69
|
1.15
|
1.000
|
3789.44
|
5681.45
|
|
Difference study group 3
|
0.97
|
0.75
|
1.26
|
1.000
|
3566.36
|
6129.10
|
|
Random Effects
|
|
sd(Intercept)
|
0.31
|
0.23
|
0.40
|
1.00
|
3752.77
|
6223.68
|
|
sd(Daily perceived persuasion target -> target)
|
0.05
|
0.02
|
0.08
|
1.00
|
6222.14
|
7438.24
|
|
sd(Daily perceived persuasion target -> agent)
|
0.05
|
0.02
|
0.08
|
1.00
|
5379.76
|
4726.82
|
|
sd(Daily perceived pressure target -> target)
|
0.05
|
0.00
|
0.14
|
1.00
|
5794.29
|
6753.92
|
|
sd(Daily perceived pressure target -> agent)
|
0.03
|
0.00
|
0.10
|
1.00
|
7900.31
|
6853.72
|
|
sd(Daily perceived pushing target -> target)
|
0.06
|
0.00
|
0.14
|
1.00
|
3065.03
|
6160.59
|
|
sd(Daily perceived pushing target -> agent)
|
0.03
|
0.00
|
0.08
|
1.00
|
6210.15
|
6587.85
|
|
Additional Parameters
|
|
ar[1]
|
0.30
|
0.26
|
0.33
|
1.00
|
19387.01
|
8198.04
|
|
nu
|
NA
|
NA
|
NA
|
NA
|
NA
|
NA
|
|
shape
|
NA
|
NA
|
NA
|
NA
|
NA
|
NA
|
|
sderr
|
NA
|
NA
|
NA
|
NA
|
NA
|
NA
|
|
sigma
|
0.55
|
0.54
|
0.57
|
1.00
|
17059.91
|
9199.99
|
Affect
range(df_double$aff, na.rm = T)
## [1] 1 6
hist(df_double$aff, breaks = 15)

formula <- bf(
aff ~
persuasion_self_cw + persuasion_partner_cw +
pressure_self_cw + pressure_partner_cw +
pushing_self_cw + pushing_partner_cw +
#barriers_self_cw +
support_self_cw + support_partner_cw +
#comf_self_cw + reas_self_cw +
isWeekend +
got_JITAI_self + skilled_support +
persuasion_self_cb + persuasion_partner_cb +
pressure_self_cb + pressure_partner_cb +
pushing_self_cb + pushing_partner_cb +
studyGroup +
day +
# Random effects
(persuasion_self_cw + persuasion_partner_cw +
pressure_self_cw + pressure_partner_cw +
pushing_self_cw + pushing_partner_cw | coupleID),
autocor = ~ ar(time = day, gr = coupleID:userID, p = 1)
)
prior1 <- c(
brms::set_prior("normal(0, 5)", class = "b"),
brms::set_prior("normal(0, 20)", class = "Intercept", lb=0, ub=6), # range of the outcome scale
brms::set_prior("normal(0, 2)", class = "sd", group = "coupleID", lb = 0),
brms::set_prior("cauchy(0, 5)", class = "ar", lb = -1, ub = 1),
brms::set_prior("cauchy(0, 10)", class = "sigma", lb = 0)
)
df_minimal <- df_double[, c("userID", all.vars(as.formula(formula)))]
mood <- my_brm(
mi = use_mi,
imputed_data = implist,
formula = formula,
prior = prior1,
data = df_double,
family = gaussian(),
#control = list(adapt_delta = 0.95, max_treedepth = 15),
iter = 5000,
warmup = 2000,
chains = 4,
cores = 4,
seed = 7777,
file = file.path(working_directory, "models_cache", "mood")
)
pp_check(mood, type='hist')
## Using 10 posterior draws for ppc type 'hist' by default.
## `stat_bin()` using `bins = 30`. Pick better value with `binwidth`.

## Using 10 posterior draws for ppc type 'dens_overlay' by default.

##
## Computed from 12000 by 3732 log-likelihood matrix.
##
## Estimate SE
## elpd_loo -4788.7 63.9
## p_loo 94.2 4.8
## looic 9577.4 127.8
## ------
## MCSE of elpd_loo is 0.1.
## MCSE and ESS estimates assume MCMC draws (r_eff in [0.5, 1.5]).
##
## All Pareto k estimates are good (k < 0.7).
## See help('pareto-k-diagnostic') for details.











summarize_brms(
mood,
model_rows_fixed = model_rows_fixed,
model_rows_random = model_rows_random,
model_rownames_fixed = model_rownames_fixed,
model_rownames_random = model_rownames_random,
exponentiate = F) %>%
print_df(rows_to_pack = rows_to_pack)
|
|
b
|
l-95% CI
|
u-95% CI
|
Rhat
|
Bulk_ESS
|
Tail_ESS
|
|
Intercept
|
4.66*
|
4.33
|
4.98
|
1.001
|
5333.50
|
7555.67
|
|
Within-Person Effects
|
|
Daily perceived persuasion target -> target
|
-0.04*
|
-0.07
|
0.00
|
1.000
|
17851.79
|
9377.35
|
|
Daily perceived persuasion target -> agent
|
-0.01
|
-0.05
|
0.03
|
1.000
|
15771.31
|
9712.42
|
|
Daily perceived pressure target -> target
|
-0.06
|
-0.18
|
0.05
|
1.000
|
13301.84
|
8210.54
|
|
Daily perceived pressure target -> agent
|
-0.03
|
-0.17
|
0.09
|
1.001
|
12005.89
|
8219.22
|
|
Daily perceived pushing target -> target
|
0.00
|
-0.06
|
0.06
|
1.000
|
16381.60
|
9400.70
|
|
Daily perceived pushing target -> agent
|
0.05
|
-0.01
|
0.10
|
1.001
|
17264.82
|
10239.34
|
|
Day
|
0.24*
|
0.03
|
0.46
|
1.001
|
19351.37
|
9299.19
|
|
Daily weartime
|
NA
|
NA
|
NA
|
NA
|
NA
|
NA
|
|
Daily perceived support target -> target
|
0.08*
|
0.05
|
0.10
|
1.000
|
23913.91
|
9489.23
|
|
Daily perceived support target -> agent
|
0.03*
|
0.00
|
0.05
|
1.001
|
24434.47
|
9707.31
|
|
Is a weekend
|
0.10*
|
0.04
|
0.17
|
1.001
|
25691.27
|
8223.61
|
|
JITAI received
|
-0.08*
|
-0.16
|
-0.01
|
1.001
|
23978.67
|
8316.33
|
|
Days post skilled support intervention
|
0.01
|
-0.14
|
0.17
|
1.001
|
18552.03
|
9823.06
|
|
Between-Person Effects
|
|
Mean perceived persuasion target -> target
|
0.38
|
-0.16
|
0.94
|
1.001
|
4243.21
|
6996.33
|
|
Mean Perceived persuasion target -> agent
|
0.30
|
-0.25
|
0.85
|
1.001
|
4329.37
|
6922.11
|
|
Mean Perceived pressure target -> target
|
-0.32
|
-0.89
|
0.24
|
1.001
|
5643.10
|
8053.99
|
|
Mean Perceived pressure target -> agent
|
-0.28
|
-0.85
|
0.29
|
1.001
|
5831.13
|
8614.96
|
|
Mean Perceived pushing target -> target
|
0.17
|
-0.60
|
0.94
|
1.000
|
6173.45
|
7735.82
|
|
Mean Perceived pushing target -> agent
|
0.28
|
-0.50
|
1.05
|
1.001
|
5957.39
|
7327.67
|
|
Mean weartime
|
NA
|
NA
|
NA
|
NA
|
NA
|
NA
|
|
Difference study group 2
|
-0.23
|
-0.67
|
0.22
|
1.000
|
5150.59
|
7479.79
|
|
Difference study group 3
|
0.36
|
-0.11
|
0.81
|
1.001
|
5116.81
|
6938.44
|
|
Random Effects
|
|
sd(Intercept)
|
0.55
|
0.42
|
0.72
|
1.00
|
4671.17
|
6976.73
|
|
sd(Daily perceived persuasion target -> target)
|
0.03
|
0.00
|
0.07
|
1.00
|
5883.93
|
6260.34
|
|
sd(Daily perceived persuasion target -> agent)
|
0.06
|
0.01
|
0.11
|
1.00
|
3841.53
|
4179.94
|
|
sd(Daily perceived pressure target -> target)
|
0.12
|
0.01
|
0.30
|
1.00
|
4294.86
|
6686.57
|
|
sd(Daily perceived pressure target -> agent)
|
0.17
|
0.02
|
0.36
|
1.00
|
3932.17
|
4325.13
|
|
sd(Daily perceived pushing target -> target)
|
0.08
|
0.01
|
0.17
|
1.00
|
4416.36
|
3438.63
|
|
sd(Daily perceived pushing target -> agent)
|
0.04
|
0.00
|
0.12
|
1.00
|
6352.21
|
7697.95
|
|
Additional Parameters
|
|
ar[1]
|
0.45
|
0.42
|
0.48
|
1.00
|
20935.05
|
9314.02
|
|
nu
|
NA
|
NA
|
NA
|
NA
|
NA
|
NA
|
|
shape
|
NA
|
NA
|
NA
|
NA
|
NA
|
NA
|
|
sderr
|
NA
|
NA
|
NA
|
NA
|
NA
|
NA
|
|
sigma
|
0.86
|
0.84
|
0.88
|
1.00
|
20987.51
|
7558.74
|
reactance
range(df_double$reactance, na.rm = T)
## [1] 0 5
hist(df_double$reactance, breaks = 6)

formula <- bf(
reactance ~
persuasion_self_cw + persuasion_partner_cw +
pressure_self_cw + pressure_partner_cw +
pushing_self_cw + pushing_partner_cw +
#barriers_self_cw +
support_self_cw + support_partner_cw +
#comf_self_cw + reas_self_cw +
isWeekend +
got_JITAI_self + skilled_support +
persuasion_self_cb + persuasion_partner_cb +
pressure_self_cb + pressure_partner_cb +
pushing_self_cb + pushing_partner_cb +
studyGroup +
day +
# Random effects
(persuasion_self_cw + persuasion_partner_cw +
pressure_self_cw + pressure_partner_cw +
pushing_self_cw + pushing_partner_cw | coupleID),
autocor = ~ ar(time = day, gr = coupleID:userID, p = 1)
)
prior1 <- c(
brms::set_prior("normal(0, 5)", class = "b"),
brms::set_prior("normal(0, 20)", class = "Intercept", lb=0, ub=5), # range of the outcome scale
brms::set_prior("normal(0, 2)", class = "sd", group = "coupleID", lb = 0),
brms::set_prior("cauchy(0, 5)", class = "ar", lb = -1, ub = 1),
brms::set_prior("cauchy(0, 10)", class = "sigma", lb = 0)
)
df_minimal <- df_double[, c("userID", all.vars(as.formula(formula)))]
reactance <- my_brm(
mi = use_mi,
imputed_data = implist,
formula = formula,
prior = prior1,
data = df_double,
family = gaussian(),
#control = list(adapt_delta = 0.95, max_treedepth = 15),
iter = 5000,
warmup = 2000,
chains = 4,
cores = 4,
seed = 7777,
file = file.path(working_directory, "models_cache", "reactance")
)
pp_check(reactance, type='hist')
## Using 10 posterior draws for ppc type 'hist' by default.
## `stat_bin()` using `bins = 30`. Pick better value with `binwidth`.

## Using 10 posterior draws for ppc type 'dens_overlay' by default.

##
## Computed from 12000 by 755 log-likelihood matrix.
##
## Estimate SE
## elpd_loo -1057.4 35.1
## p_loo 75.9 7.3
## looic 2114.7 70.3
## ------
## MCSE of elpd_loo is NA.
## MCSE and ESS estimates assume MCMC draws (r_eff in [0.4, 1.4]).
##
## Pareto k diagnostic values:
## Count Pct. Min. ESS
## (-Inf, 0.7] (good) 747 98.9% 202
## (0.7, 1] (bad) 8 1.1% <NA>
## (1, Inf) (very bad) 0 0.0% <NA>
## See help('pareto-k-diagnostic') for details.
plot(reactance, ask = FALSE)











## Family: gaussian
## Links: mu = identity; sigma = identity
## Formula: reactance ~ persuasion_self_cw + persuasion_partner_cw + pressure_self_cw + pressure_partner_cw + pushing_self_cw + pushing_partner_cw + support_self_cw + support_partner_cw + isWeekend + got_JITAI_self + skilled_support + persuasion_self_cb + persuasion_partner_cb + pressure_self_cb + pressure_partner_cb + pushing_self_cb + pushing_partner_cb + studyGroup + day + (persuasion_self_cw + persuasion_partner_cw + pressure_self_cw + pressure_partner_cw + pushing_self_cw + pushing_partner_cw | coupleID)
## autocor ~ ar(time = day, gr = coupleID:userID, p = 1)
## Data: data (Number of observations: 755)
## Draws: 4 chains, each with iter = 5000; warmup = 2000; thin = 1;
## total post-warmup draws = 12000
##
## Correlation Structures:
## Estimate Est.Error l-95% CI u-95% CI Rhat Bulk_ESS Tail_ESS
## ar[1] 0.02 0.04 -0.06 0.11 1.00 9970 8716
##
## Multilevel Hyperparameters:
## ~coupleID (Number of levels: 38)
## Estimate Est.Error l-95% CI u-95% CI Rhat
## sd(Intercept) 0.19 0.08 0.03 0.35 1.00
## sd(persuasion_self_cw) 0.04 0.03 0.00 0.11 1.00
## sd(persuasion_partner_cw) 0.04 0.03 0.00 0.13 1.00
## sd(pressure_self_cw) 0.39 0.10 0.22 0.61 1.00
## sd(pressure_partner_cw) 0.21 0.15 0.01 0.57 1.00
## sd(pushing_self_cw) 0.12 0.06 0.01 0.23 1.00
## sd(pushing_partner_cw) 0.05 0.04 0.00 0.15 1.00
## cor(Intercept,persuasion_self_cw) -0.22 0.36 -0.81 0.53 1.00
## cor(Intercept,persuasion_partner_cw) 0.06 0.34 -0.61 0.70 1.00
## cor(persuasion_self_cw,persuasion_partner_cw) -0.03 0.35 -0.69 0.64 1.00
## cor(Intercept,pressure_self_cw) 0.03 0.31 -0.57 0.61 1.00
## cor(persuasion_self_cw,pressure_self_cw) -0.00 0.34 -0.64 0.64 1.00
## cor(persuasion_partner_cw,pressure_self_cw) 0.00 0.35 -0.66 0.65 1.00
## cor(Intercept,pressure_partner_cw) 0.04 0.33 -0.59 0.66 1.00
## cor(persuasion_self_cw,pressure_partner_cw) 0.05 0.36 -0.64 0.70 1.00
## cor(persuasion_partner_cw,pressure_partner_cw) -0.01 0.35 -0.67 0.66 1.00
## cor(pressure_self_cw,pressure_partner_cw) -0.16 0.32 -0.71 0.51 1.00
## cor(Intercept,pushing_self_cw) 0.15 0.32 -0.49 0.73 1.00
## cor(persuasion_self_cw,pushing_self_cw) -0.04 0.35 -0.68 0.63 1.00
## cor(persuasion_partner_cw,pushing_self_cw) 0.09 0.35 -0.60 0.72 1.00
## cor(pressure_self_cw,pushing_self_cw) -0.13 0.31 -0.68 0.49 1.00
## cor(pressure_partner_cw,pushing_self_cw) 0.05 0.35 -0.63 0.70 1.00
## cor(Intercept,pushing_partner_cw) 0.04 0.35 -0.64 0.67 1.00
## cor(persuasion_self_cw,pushing_partner_cw) 0.00 0.35 -0.65 0.66 1.00
## cor(persuasion_partner_cw,pushing_partner_cw) -0.03 0.36 -0.70 0.65 1.00
## cor(pressure_self_cw,pushing_partner_cw) -0.06 0.35 -0.70 0.61 1.00
## cor(pressure_partner_cw,pushing_partner_cw) 0.02 0.36 -0.66 0.69 1.00
## cor(pushing_self_cw,pushing_partner_cw) 0.05 0.35 -0.64 0.70 1.00
## Bulk_ESS Tail_ESS
## sd(Intercept) 2898 2874
## sd(persuasion_self_cw) 3930 5676
## sd(persuasion_partner_cw) 4487 4544
## sd(pressure_self_cw) 5865 7215
## sd(pressure_partner_cw) 3081 5104
## sd(pushing_self_cw) 2958 3046
## sd(pushing_partner_cw) 7151 5983
## cor(Intercept,persuasion_self_cw) 8156 8739
## cor(Intercept,persuasion_partner_cw) 12830 8935
## cor(persuasion_self_cw,persuasion_partner_cw) 11546 9110
## cor(Intercept,pressure_self_cw) 3298 5245
## cor(persuasion_self_cw,pressure_self_cw) 3200 5698
## cor(persuasion_partner_cw,pressure_self_cw) 2918 4873
## cor(Intercept,pressure_partner_cw) 8214 8303
## cor(persuasion_self_cw,pressure_partner_cw) 8112 9219
## cor(persuasion_partner_cw,pressure_partner_cw) 8244 9072
## cor(pressure_self_cw,pressure_partner_cw) 9917 8359
## cor(Intercept,pushing_self_cw) 5937 8092
## cor(persuasion_self_cw,pushing_self_cw) 5419 7694
## cor(persuasion_partner_cw,pushing_self_cw) 5235 7804
## cor(pressure_self_cw,pushing_self_cw) 8008 9156
## cor(pressure_partner_cw,pushing_self_cw) 5960 9732
## cor(Intercept,pushing_partner_cw) 15007 8839
## cor(persuasion_self_cw,pushing_partner_cw) 13519 9399
## cor(persuasion_partner_cw,pushing_partner_cw) 10267 8818
## cor(pressure_self_cw,pushing_partner_cw) 12715 9426
## cor(pressure_partner_cw,pushing_partner_cw) 9517 8910
## cor(pushing_self_cw,pushing_partner_cw) 10551 9877
##
## Regression Coefficients:
## Estimate Est.Error l-95% CI u-95% CI Rhat Bulk_ESS
## Intercept 0.69 0.13 0.45 0.94 1.00 9782
## persuasion_self_cw -0.02 0.03 -0.08 0.04 1.00 11948
## persuasion_partner_cw 0.02 0.03 -0.05 0.09 1.00 11719
## pressure_self_cw 0.25 0.11 0.04 0.46 1.00 6527
## pressure_partner_cw 0.13 0.11 -0.06 0.36 1.00 6266
## pushing_self_cw 0.11 0.04 0.02 0.20 1.00 8233
## pushing_partner_cw -0.00 0.04 -0.09 0.08 1.00 13127
## support_self_cw -0.08 0.03 -0.13 -0.02 1.00 13393
## support_partner_cw -0.02 0.03 -0.08 0.03 1.00 14088
## isWeekendWeekend -0.12 0.08 -0.28 0.03 1.00 15902
## got_JITAI_selfJITAIreceived -0.01 0.11 -0.22 0.20 1.00 13319
## skilled_supportDaysafterIntervention -0.09 0.13 -0.34 0.17 1.00 8060
## persuasion_self_cb 0.05 0.17 -0.29 0.39 1.00 5949
## persuasion_partner_cb 0.06 0.19 -0.32 0.44 1.00 6706
## pressure_self_cb 0.58 0.20 0.20 0.97 1.00 7419
## pressure_partner_cb 0.24 0.21 -0.18 0.66 1.00 6869
## pushing_self_cb -0.19 0.26 -0.69 0.32 1.00 7353
## pushing_partner_cb -0.56 0.28 -1.10 0.00 1.00 8683
## studyGroupFirst3weeksinterventions 0.08 0.13 -0.19 0.34 1.00 8011
## studyGrouplast3weeksinterventions -0.33 0.14 -0.61 -0.05 1.00 6071
## day 0.13 0.19 -0.24 0.50 1.00 9201
## Tail_ESS
## Intercept 9758
## persuasion_self_cw 9382
## persuasion_partner_cw 8591
## pressure_self_cw 7771
## pressure_partner_cw 5576
## pushing_self_cw 8965
## pushing_partner_cw 8637
## support_self_cw 8760
## support_partner_cw 9370
## isWeekendWeekend 9228
## got_JITAI_selfJITAIreceived 9708
## skilled_supportDaysafterIntervention 8869
## persuasion_self_cb 7203
## persuasion_partner_cb 7438
## pressure_self_cb 7886
## pressure_partner_cb 8105
## pushing_self_cb 8514
## pushing_partner_cb 8277
## studyGroupFirst3weeksinterventions 7901
## studyGrouplast3weeksinterventions 7951
## day 9223
##
## Further Distributional Parameters:
## Estimate Est.Error l-95% CI u-95% CI Rhat Bulk_ESS Tail_ESS
## sigma 0.93 0.03 0.88 0.98 1.00 10201 8354
##
## Draws were sampled using sample(hmc). For each parameter, Bulk_ESS
## and Tail_ESS are effective sample size measures, and Rhat is the potential
## scale reduction factor on split chains (at convergence, Rhat = 1).
summarize_brms(
reactance,
model_rows_fixed = model_rows_fixed,
model_rows_random = model_rows_random,
model_rownames_fixed = model_rownames_fixed,
model_rownames_random = model_rownames_random,
exponentiate = F) %>%
print_df(rows_to_pack = rows_to_pack)
|
|
b
|
l-95% CI
|
u-95% CI
|
Rhat
|
Bulk_ESS
|
Tail_ESS
|
|
Intercept
|
0.69*
|
0.45
|
0.94
|
1.000
|
9781.55
|
9757.83
|
|
Within-Person Effects
|
|
Daily perceived persuasion target -> target
|
-0.02
|
-0.08
|
0.04
|
1.000
|
11947.63
|
9382.08
|
|
Daily perceived persuasion target -> agent
|
0.02
|
-0.05
|
0.09
|
1.000
|
11718.77
|
8591.41
|
|
Daily perceived pressure target -> target
|
0.25*
|
0.04
|
0.46
|
1.000
|
6527.47
|
7771.44
|
|
Daily perceived pressure target -> agent
|
0.13
|
-0.06
|
0.36
|
1.001
|
6265.78
|
5575.91
|
|
Daily perceived pushing target -> target
|
0.11*
|
0.02
|
0.20
|
1.000
|
8233.20
|
8964.64
|
|
Daily perceived pushing target -> agent
|
0.00
|
-0.09
|
0.08
|
1.000
|
13126.55
|
8636.78
|
|
Day
|
0.13
|
-0.24
|
0.50
|
1.000
|
9200.75
|
9222.94
|
|
Daily weartime
|
NA
|
NA
|
NA
|
NA
|
NA
|
NA
|
|
Daily perceived support target -> target
|
-0.08*
|
-0.13
|
-0.02
|
1.000
|
13393.09
|
8759.59
|
|
Daily perceived support target -> agent
|
-0.02
|
-0.08
|
0.03
|
1.000
|
14087.96
|
9370.01
|
|
Is a weekend
|
-0.12
|
-0.28
|
0.03
|
1.000
|
15902.22
|
9228.47
|
|
JITAI received
|
-0.01
|
-0.22
|
0.20
|
1.000
|
13318.51
|
9708.20
|
|
Days post skilled support intervention
|
-0.09
|
-0.34
|
0.17
|
1.000
|
8060.22
|
8869.24
|
|
Between-Person Effects
|
|
Mean perceived persuasion target -> target
|
0.05
|
-0.29
|
0.39
|
1.000
|
5948.63
|
7203.02
|
|
Mean Perceived persuasion target -> agent
|
0.06
|
-0.32
|
0.44
|
1.000
|
6705.99
|
7438.37
|
|
Mean Perceived pressure target -> target
|
0.58*
|
0.20
|
0.97
|
1.000
|
7418.87
|
7885.74
|
|
Mean Perceived pressure target -> agent
|
0.24
|
-0.18
|
0.66
|
1.001
|
6869.15
|
8105.16
|
|
Mean Perceived pushing target -> target
|
-0.19
|
-0.69
|
0.32
|
1.000
|
7352.72
|
8513.58
|
|
Mean Perceived pushing target -> agent
|
-0.56
|
-1.10
|
0.00
|
1.000
|
8682.65
|
8277.21
|
|
Mean weartime
|
NA
|
NA
|
NA
|
NA
|
NA
|
NA
|
|
Difference study group 2
|
0.08
|
-0.19
|
0.34
|
1.000
|
8011.43
|
7900.90
|
|
Difference study group 3
|
-0.33*
|
-0.61
|
-0.05
|
1.000
|
6071.00
|
7951.32
|
|
Random Effects
|
|
sd(Intercept)
|
0.19
|
0.03
|
0.35
|
1.00
|
2898.25
|
2873.61
|
|
sd(Daily perceived persuasion target -> target)
|
0.04
|
0.00
|
0.11
|
1.00
|
3929.52
|
5675.83
|
|
sd(Daily perceived persuasion target -> agent)
|
0.04
|
0.00
|
0.13
|
1.00
|
4487.18
|
4543.64
|
|
sd(Daily perceived pressure target -> target)
|
0.39
|
0.22
|
0.61
|
1.00
|
5864.69
|
7215.12
|
|
sd(Daily perceived pressure target -> agent)
|
0.21
|
0.01
|
0.57
|
1.00
|
3080.53
|
5104.17
|
|
sd(Daily perceived pushing target -> target)
|
0.12
|
0.01
|
0.23
|
1.00
|
2957.93
|
3046.23
|
|
sd(Daily perceived pushing target -> agent)
|
0.05
|
0.00
|
0.15
|
1.00
|
7151.26
|
5982.57
|
|
Additional Parameters
|
|
ar[1]
|
0.02
|
-0.06
|
0.11
|
1.00
|
9969.53
|
8715.68
|
|
nu
|
NA
|
NA
|
NA
|
NA
|
NA
|
NA
|
|
shape
|
NA
|
NA
|
NA
|
NA
|
NA
|
NA
|
|
sderr
|
NA
|
NA
|
NA
|
NA
|
NA
|
NA
|
|
sigma
|
0.93
|
0.88
|
0.98
|
1.00
|
10200.99
|
8354.22
|
Binary Version
introduce_binary_reactance <- function(data) {
data$is_reactance <- factor(data$reactance > 0, levels = c(FALSE, TRUE), labels = c(0, 1))
return(data)
}
df_double <- introduce_binary_reactance(df_double)
if (use_mi) {
for (i in seq_along(implist)) {
implist[[i]] <- introduce_binary_reactance(implist[[i]])
}
}
formula <- bf(
is_reactance ~
persuasion_self_cw + persuasion_partner_cw +
pressure_self_cw + pressure_partner_cw +
pushing_self_cw + pushing_partner_cw +
#barriers_self_cw +
support_self_cw + support_partner_cw +
#comf_self_cw + reas_self_cw +
isWeekend +
got_JITAI_self + skilled_support +
persuasion_self_cb + persuasion_partner_cb +
pressure_self_cb + pressure_partner_cb +
pushing_self_cb + pushing_partner_cb +
studyGroup +
day +
# Random effects
(persuasion_self_cw + persuasion_partner_cw +
pressure_self_cw + pressure_partner_cw +
pushing_self_cw + pushing_partner_cw | coupleID),
autocor = ~ ar(time = day, gr = coupleID:userID, p = 1)
)
prior1 <- c(
brms::set_prior("normal(0, 5)", class = "b"),
brms::set_prior("normal(0, 20)", class = "Intercept", lb=0, ub=5), # range of the outcome scale
brms::set_prior("normal(0, 2)", class = "sd", group = "coupleID", lb = 0),
brms::set_prior("cauchy(0, 5)", class = "ar", lb = -1, ub = 1)
#brms::set_prior("cauchy(0, 10)", class = "sigma", lb = 0)
)
df_minimal <- df_double[, c("userID", all.vars(as.formula(formula)))]
is_reactance <- my_brm(
mi = use_mi,
imputed_data = implist,
formula = formula,
prior = prior1,
data = df_double,
family = bernoulli(),
#control = list(adapt_delta = 0.95, max_treedepth = 15),
iter = 5000,
warmup = 2000,
chains = 4,
cores = 4,
seed = 7777,
file = file.path(working_directory, "models_cache", "is_reactance")
)
pp_check(is_reactance, type='hist')
## Using 10 posterior draws for ppc type 'hist' by default.
## `stat_bin()` using `bins = 30`. Pick better value with `binwidth`.

## Using 10 posterior draws for ppc type 'dens_overlay' by default.

##
## Computed from 12000 by 755 log-likelihood matrix.
##
## Estimate SE
## elpd_loo -507.4 22.1
## p_loo 467.6 21.1
## looic 1014.9 44.2
## ------
## MCSE of elpd_loo is NA.
## MCSE and ESS estimates assume MCMC draws (r_eff in [0.6, 1.2]).
##
## Pareto k diagnostic values:
## Count Pct. Min. ESS
## (-Inf, 0.7] (good) 0 0.0% <NA>
## (0.7, 1] (bad) 135 17.9% <NA>
## (1, Inf) (very bad) 620 82.1% <NA>
## See help('pareto-k-diagnostic') for details.
plot(is_reactance, ask = FALSE)











summarize_brms(
is_reactance,
model_rows_fixed = model_rows_fixed,
model_rows_random = model_rows_random,
model_rownames_fixed = model_rownames_fixed,
model_rownames_random = model_rownames_random,
exponentiate = T) %>%
print_df(rows_to_pack = rows_to_pack)
|
|
OR
|
l-95% CI
|
u-95% CI
|
Rhat
|
Bulk_ESS
|
Tail_ESS
|
|
Intercept
|
0.01*
|
0.00
|
0.61
|
1.000
|
6050.32
|
7352.81
|
|
Within-Person Effects
|
|
Daily perceived persuasion target -> target
|
0.57
|
0.17
|
1.76
|
1.001
|
5213.94
|
6546.91
|
|
Daily perceived persuasion target -> agent
|
4.56
|
0.93
|
32.98
|
1.003
|
3965.22
|
6309.03
|
|
Daily perceived pressure target -> target
|
48.19*
|
4.21
|
852.81
|
1.001
|
5268.32
|
6233.23
|
|
Daily perceived pressure target -> agent
|
2.36
|
0.11
|
59.23
|
1.000
|
6983.99
|
7542.84
|
|
Daily perceived pushing target -> target
|
5.98*
|
1.49
|
35.94
|
1.001
|
4902.62
|
5963.54
|
|
Daily perceived pushing target -> agent
|
0.70
|
0.09
|
4.89
|
1.000
|
6466.07
|
7702.55
|
|
Day
|
10.52
|
0.05
|
2451.97
|
1.000
|
7136.10
|
8024.49
|
|
Daily weartime
|
NA
|
NA
|
NA
|
NA
|
NA
|
NA
|
|
Daily perceived support target -> target
|
0.31*
|
0.10
|
0.82
|
1.001
|
4978.03
|
6477.69
|
|
Daily perceived support target -> agent
|
0.53
|
0.18
|
1.39
|
1.001
|
5401.61
|
6172.94
|
|
Is a weekend
|
0.14
|
0.01
|
2.43
|
1.000
|
6459.38
|
7673.06
|
|
JITAI received
|
4.68
|
0.14
|
159.81
|
1.000
|
6316.13
|
7448.09
|
|
Days post skilled support intervention
|
0.55
|
0.01
|
28.28
|
1.000
|
6288.79
|
7923.51
|
|
Between-Person Effects
|
|
Mean perceived persuasion target -> target
|
66.11
|
0.46
|
17024.80
|
1.001
|
5611.04
|
7517.88
|
|
Mean Perceived persuasion target -> agent
|
8.48
|
0.05
|
1612.05
|
1.000
|
7696.64
|
8290.67
|
|
Mean Perceived pressure target -> target
|
19482.91*
|
18.26
|
22559684.51
|
1.000
|
8692.18
|
8590.93
|
|
Mean Perceived pressure target -> agent
|
140.30
|
0.09
|
275758.29
|
1.000
|
8159.80
|
7863.27
|
|
Mean Perceived pushing target -> target
|
7.91
|
0.01
|
10571.02
|
1.001
|
8600.19
|
8750.39
|
|
Mean Perceived pushing target -> agent
|
0.00
|
0.00
|
2.31
|
1.001
|
8400.86
|
8827.26
|
|
Mean weartime
|
NA
|
NA
|
NA
|
NA
|
NA
|
NA
|
|
Difference study group 2
|
5.46
|
0.05
|
833.67
|
1.001
|
5821.40
|
7469.84
|
|
Difference study group 3
|
0.01
|
0.00
|
1.21
|
1.001
|
6886.18
|
7868.72
|
|
Random Effects
|
|
sd(Intercept)
|
4.71
|
2.70
|
7.09
|
1.00
|
5000.79
|
6182.43
|
|
sd(Daily perceived persuasion target -> target)
|
1.00
|
0.04
|
2.58
|
1.00
|
2080.97
|
4750.12
|
|
sd(Daily perceived persuasion target -> agent)
|
2.29
|
0.69
|
4.23
|
1.00
|
3604.76
|
3629.11
|
|
sd(Daily perceived pressure target -> target)
|
2.04
|
0.09
|
5.04
|
1.00
|
2538.18
|
5173.40
|
|
sd(Daily perceived pressure target -> agent)
|
1.53
|
0.06
|
4.27
|
1.00
|
5985.31
|
6525.88
|
|
sd(Daily perceived pushing target -> target)
|
1.31
|
0.08
|
3.06
|
1.00
|
3341.40
|
4948.99
|
|
sd(Daily perceived pushing target -> agent)
|
0.99
|
0.04
|
2.89
|
1.00
|
5925.78
|
7178.45
|
|
Additional Parameters
|
|
ar[1]
|
0.10
|
-0.09
|
0.29
|
1.00
|
2142.56
|
3615.44
|
|
nu
|
NA
|
NA
|
NA
|
NA
|
NA
|
NA
|
|
shape
|
NA
|
NA
|
NA
|
NA
|
NA
|
NA
|
|
sderr
|
10.96
|
7.06
|
16.02
|
1.00
|
3114.28
|
5302.78
|
|
sigma
|
NA
|
NA
|
NA
|
NA
|
NA
|
NA
|
Report All Models
if (report_ordinal) {
model_rows_random_final <- model_rows_random_ordinal
model_rows_fixed_final <- model_rows_fixed_ordinal
model_rownames_fixed_final <- model_rownames_fixed_ordinal
model_rownames_random_final <- model_rownames_random_ordinal
rows_to_pack_final <- rows_to_pack_ordinal
} else {
model_rows_random_final <- model_rows_random
model_rows_fixed_final <- model_rows_fixed
model_rownames_fixed_final <- model_rownames_fixed
model_rownames_random_final <- model_rownames_random
rows_to_pack_final <- rows_to_pack
}
all_models <- report_side_by_side(
pa_sub,
pa_obj_log,
mood,
reactance,
is_reactance,
model_rows_random = model_rows_random_final,
model_rows_fixed = model_rows_fixed_final,
model_rownames_random = model_rownames_random_final,
model_rownames_fixed = model_rownames_fixed_final
)
## [1] "pa_sub"
## [1] "pa_obj_log"
## [1] "mood"
## [1] "reactance"
## [1] "is_reactance"
# pretty printing
summary_all_models <- all_models %>%
print_df(rows_to_pack = rows_to_pack_final) %>%
add_header_above(
c(" ", "Subjective MVPA" = 2,
"Device-Based MVPA" = 2,
"Mood" = 2,
"Reactance Gaussian" = 2,
"Reactance Dichotome" = 2)
)
export_xlsx(summary_all_models,
rows_to_pack = rows_to_pack_final,
file.path(working_directory, "Output", "AllCovariates_SensCovariates.xlsx"),
merge_option = 'both',
simplify_2nd_row = TRUE,
colwidths = c(40, 7.4, 12.85, 7.4, 12.85,7.4, 12.85,7.4, 12.85,7.4, 12.85),
line_above_rows = c(1,2,3,28),
line_below_rows = c(-1))
summary_all_models
|
|
Subjective MVPA
|
Device-Based MVPA
|
Mood
|
Reactance Gaussian
|
Reactance Dichotome
|
|
|
IRR pa_sub
|
95% CI pa_sub
|
exp(Est.) pa_obj_log
|
95% CI pa_obj_log
|
b mood
|
95% CI mood
|
b reactance
|
95% CI reactance
|
OR is_reactance
|
95% CI is_reactance
|
|
Intercept
|
26.72*
|
[17.32, 41.49]
|
121.23*
|
[100.82, 145.60]
|
4.66*
|
[ 4.33, 4.98]
|
0.69*
|
[ 0.45, 0.94]
|
0.01*
|
[ 0.00, 0.61]
|
|
Within-Person Effects
|
|
Daily perceived persuasion target -> target
|
1.05
|
[ 0.94, 1.18]
|
1.01
|
[ 0.98, 1.04]
|
-0.04*
|
[-0.07, 0.00]
|
-0.02
|
[-0.08, 0.04]
|
0.57
|
[ 0.17, 1.76]
|
|
Daily perceived persuasion target -> agent
|
1.04
|
[ 0.93, 1.17]
|
1.00
|
[ 0.97, 1.03]
|
-0.01
|
[-0.05, 0.03]
|
0.02
|
[-0.05, 0.09]
|
4.56
|
[ 0.93, 32.98]
|
|
Daily perceived pressure target -> target
|
0.94
|
[ 0.71, 1.28]
|
0.95
|
[ 0.89, 1.01]
|
-0.06
|
[-0.18, 0.05]
|
0.25*
|
[ 0.04, 0.46]
|
48.19*
|
[ 4.21, 852.81]
|
|
Daily perceived pressure target -> agent
|
1.21
|
[ 0.90, 1.67]
|
0.98
|
[ 0.92, 1.04]
|
-0.03
|
[-0.17, 0.09]
|
0.13
|
[-0.06, 0.36]
|
2.36
|
[ 0.11, 59.23]
|
|
Daily perceived pushing target -> target
|
1.08
|
[ 0.89, 1.34]
|
1.02
|
[ 0.97, 1.06]
|
0.00
|
[-0.06, 0.06]
|
0.11*
|
[ 0.02, 0.20]
|
5.98*
|
[ 1.49, 35.94]
|
|
Daily perceived pushing target -> agent
|
1.06
|
[ 0.90, 1.27]
|
1.02
|
[ 0.98, 1.06]
|
0.05
|
[-0.01, 0.10]
|
0.00
|
[-0.09, 0.08]
|
0.70
|
[ 0.09, 4.89]
|
|
Day
|
0.96
|
[ 0.62, 1.46]
|
0.95
|
[ 0.84, 1.07]
|
0.24*
|
[ 0.03, 0.46]
|
0.13
|
[-0.24, 0.50]
|
10.52
|
[ 0.05, 2451.97]
|
|
Daily weartime
|
NA
|
NA
|
1.00*
|
[ 1.00, 1.00]
|
NA
|
NA
|
NA
|
NA
|
NA
|
NA
|
|
Daily perceived support target -> target
|
1.25*
|
[ 1.17, 1.35]
|
1.04*
|
[ 1.02, 1.05]
|
0.08*
|
[ 0.05, 0.10]
|
-0.08*
|
[-0.13, -0.02]
|
0.31*
|
[ 0.10, 0.82]
|
|
Daily perceived support target -> agent
|
1.21*
|
[ 1.11, 1.31]
|
1.02*
|
[ 1.00, 1.04]
|
0.03*
|
[ 0.00, 0.05]
|
-0.02
|
[-0.08, 0.03]
|
0.53
|
[ 0.18, 1.39]
|
|
Is a weekend
|
1.22*
|
[ 1.01, 1.50]
|
1.05*
|
[ 1.01, 1.10]
|
0.10*
|
[ 0.04, 0.17]
|
-0.12
|
[-0.28, 0.03]
|
0.14
|
[ 0.01, 2.43]
|
|
JITAI received
|
0.75*
|
[ 0.58, 0.97]
|
0.93*
|
[ 0.88, 0.98]
|
-0.08*
|
[-0.16, -0.01]
|
-0.01
|
[-0.22, 0.20]
|
4.68
|
[ 0.14, 159.81]
|
|
Days post skilled support intervention
|
0.86
|
[ 0.62, 1.19]
|
1.03
|
[ 0.94, 1.12]
|
0.01
|
[-0.14, 0.17]
|
-0.09
|
[-0.34, 0.17]
|
0.55
|
[ 0.01, 28.28]
|
|
Between-Person Effects
|
|
Mean perceived persuasion target -> target
|
1.65
|
[ 0.83, 3.26]
|
1.07
|
[ 0.80, 1.46]
|
0.38
|
[-0.16, 0.94]
|
0.05
|
[-0.29, 0.39]
|
66.11
|
[ 0.46, 17024.80]
|
|
Mean Perceived persuasion target -> agent
|
1.17
|
[ 0.60, 2.32]
|
0.94
|
[ 0.69, 1.30]
|
0.30
|
[-0.25, 0.85]
|
0.06
|
[-0.32, 0.44]
|
8.48
|
[ 0.05, 1612.05]
|
|
Mean Perceived pressure target -> target
|
0.54
|
[ 0.24, 1.21]
|
1.02
|
[ 0.73, 1.42]
|
-0.32
|
[-0.89, 0.24]
|
0.58*
|
[ 0.20, 0.97]
|
19482.91*
|
[18.26, 22559684.51]
|
|
Mean Perceived pressure target -> agent
|
0.42*
|
[ 0.19, 0.95]
|
0.98
|
[ 0.72, 1.34]
|
-0.28
|
[-0.85, 0.29]
|
0.24
|
[-0.18, 0.66]
|
140.30
|
[ 0.09, 275758.29]
|
|
Mean Perceived pushing target -> target
|
1.53
|
[ 0.55, 4.34]
|
1.02
|
[ 0.66, 1.57]
|
0.17
|
[-0.60, 0.94]
|
-0.19
|
[-0.69, 0.32]
|
7.91
|
[ 0.01, 10571.02]
|
|
Mean Perceived pushing target -> agent
|
2.03
|
[ 0.73, 5.72]
|
1.33
|
[ 0.85, 2.05]
|
0.28
|
[-0.50, 1.05]
|
-0.56
|
[-1.10, 0.00]
|
0.00
|
[ 0.00, 2.31]
|
|
Mean weartime
|
NA
|
NA
|
1.00
|
[ 1.00, 1.00]
|
NA
|
NA
|
NA
|
NA
|
NA
|
NA
|
|
Difference study group 2
|
0.80
|
[ 0.46, 1.37]
|
0.89
|
[ 0.69, 1.15]
|
-0.23
|
[-0.67, 0.22]
|
0.08
|
[-0.19, 0.34]
|
5.46
|
[ 0.05, 833.67]
|
|
Difference study group 3
|
1.12
|
[ 0.64, 1.94]
|
0.97
|
[ 0.75, 1.26]
|
0.36
|
[-0.11, 0.81]
|
-0.33*
|
[-0.61, -0.05]
|
0.01
|
[ 0.00, 1.21]
|
|
Random Effects
|
|
sd(Intercept)
|
0.64
|
[ 0.47, 0.87]
|
0.31
|
[0.23, 0.40]
|
0.55
|
[0.42, 0.72]
|
0.19
|
[ 0.03, 0.35]
|
4.71
|
[ 2.70, 7.09]
|
|
sd(Daily perceived persuasion target -> target)
|
0.07
|
[ 0.00, 0.21]
|
0.05
|
[0.02, 0.08]
|
0.03
|
[0.00, 0.07]
|
0.04
|
[ 0.00, 0.11]
|
1.00
|
[ 0.04, 2.58]
|
|
sd(Daily perceived persuasion target -> agent)
|
0.07
|
[ 0.00, 0.18]
|
0.05
|
[0.02, 0.08]
|
0.06
|
[0.01, 0.11]
|
0.04
|
[ 0.00, 0.13]
|
2.29
|
[ 0.69, 4.23]
|
|
sd(Daily perceived pressure target -> target)
|
0.17
|
[ 0.01, 0.53]
|
0.05
|
[0.00, 0.14]
|
0.12
|
[0.01, 0.30]
|
0.39
|
[ 0.22, 0.61]
|
2.04
|
[ 0.09, 5.04]
|
|
sd(Daily perceived pressure target -> agent)
|
0.18
|
[ 0.01, 0.51]
|
0.03
|
[0.00, 0.10]
|
0.17
|
[0.02, 0.36]
|
0.21
|
[ 0.01, 0.57]
|
1.53
|
[ 0.06, 4.27]
|
|
sd(Daily perceived pushing target -> target)
|
0.26
|
[ 0.01, 0.56]
|
0.06
|
[0.00, 0.14]
|
0.08
|
[0.01, 0.17]
|
0.12
|
[ 0.01, 0.23]
|
1.31
|
[ 0.08, 3.06]
|
|
sd(Daily perceived pushing target -> agent)
|
0.11
|
[ 0.00, 0.30]
|
0.03
|
[0.00, 0.08]
|
0.04
|
[0.00, 0.12]
|
0.05
|
[ 0.00, 0.15]
|
0.99
|
[ 0.04, 2.89]
|
|
Additional Parameters
|
|
ar[1]
|
0.03
|
[-0.94, 0.94]
|
0.30
|
[0.26, 0.33]
|
0.45
|
[0.42, 0.48]
|
0.02
|
[-0.06, 0.11]
|
0.10
|
[-0.09, 0.29]
|
|
nu
|
NA
|
NA
|
NA
|
NA
|
NA
|
NA
|
NA
|
NA
|
NA
|
NA
|
|
shape
|
0.14
|
[ 0.13, 0.15]
|
NA
|
NA
|
NA
|
NA
|
NA
|
NA
|
NA
|
NA
|
|
sderr
|
0.05
|
[ 0.00, 0.14]
|
NA
|
NA
|
NA
|
NA
|
NA
|
NA
|
10.96
|
[ 7.06, 16.02]
|
|
sigma
|
NA
|
NA
|
0.55
|
[0.54, 0.57]
|
0.86
|
[0.84, 0.88]
|
0.93
|
[ 0.88, 0.98]
|
NA
|
NA
|
Analyses were conducted using the R Statistical language (version
4.3.2; R Core Team, 2023) on Windows 11 x64 (build 22635)
- Allaire J, Xie Y, Dervieux C, McPherson J, Luraschi J, Ushey K,
Atkins A, Wickham H, Cheng J, Chang W, Iannone R (2024). rmarkdown:
Dynamic Documents for R. R package version 2.26, https://github.com/rstudio/rmarkdown. Xie Y, Allaire J,
Grolemund G (2018). R Markdown: The Definitive Guide. Chapman
and Hall/CRC, Boca Raton, Florida. ISBN 9781138359338, https://bookdown.org/yihui/rmarkdown. Xie Y, Dervieux C,
Riederer E (2020). R Markdown Cookbook. Chapman and Hall/CRC,
Boca Raton, Florida. ISBN 9780367563837, https://bookdown.org/yihui/rmarkdown-cookbook.
- Bengtsson H (2003). “The R.oo package - Object-Oriented Programming
with References Using Standard R Code.” In Hornik K, Leisch F, Zeileis A
(eds.), Proceedings of the 3rd International Workshop on Distributed
Statistical Computing (DSC 2003). https://www.r-project.org/conferences/DSC-2003/Proceedings/Bengtsson.pdf.
- Bengtsson H (2003). “The R.oo package - Object-Oriented Programming
with References Using Standard R Code.” In Hornik K, Leisch F, Zeileis A
(eds.), Proceedings of the 3rd International Workshop on Distributed
Statistical Computing (DSC 2003). https://www.r-project.org/conferences/DSC-2003/Proceedings/Bengtsson.pdf.
- Bengtsson H (2023). R.utils: Various Programming Utilities.
R package version 2.12.3, https://CRAN.R-project.org/package=R.utils.
- Bürkner P (2017). “brms: An R Package for Bayesian Multilevel Models
Using Stan.” Journal of Statistical Software, 80(1),
1-28. doi:10.18637/jss.v080.i01 https://doi.org/10.18637/jss.v080.i01. Bürkner P (2018).
“Advanced Bayesian Multilevel Modeling with the R Package brms.” The
R Journal, 10(1), 395-411. doi:10.32614/RJ-2018-017
https://doi.org/10.32614/RJ-2018-017. Bürkner P (2021).
“Bayesian Item Response Modeling in R with brms and Stan.” Journal
of Statistical Software, 100(5), 1-54. doi:10.18637/jss.v100.i05 https://doi.org/10.18637/jss.v100.i05.
- Eddelbuettel D, Francois R, Allaire J, Ushey K, Kou Q, Russell N,
Ucar I, Bates D, Chambers J (2024). Rcpp: Seamless R and C++
Integration. R package version 1.0.12, https://CRAN.R-project.org/package=Rcpp. Eddelbuettel D,
François R (2011). “Rcpp: Seamless R and C++ Integration.” Journal
of Statistical Software, 40(8), 1-18. doi:10.18637/jss.v040.i08 https://doi.org/10.18637/jss.v040.i08. Eddelbuettel D
(2013). Seamless R and C++ Integration with Rcpp. Springer, New
York. doi:10.1007/978-1-4614-6868-4 https://doi.org/10.1007/978-1-4614-6868-4, ISBN
978-1-4614-6867-7. Eddelbuettel D, Balamuta J (2018). “Extending R with
C++: A Brief Introduction to Rcpp.” The American Statistician,
72(1), 28-36. doi:10.1080/00031305.2017.1375990 https://doi.org/10.1080/00031305.2017.1375990.
- Gabry J, Mahr T (2024). “bayesplot: Plotting for Bayesian Models.” R
package version 1.11.1, https://mc-stan.org/bayesplot/. Gabry J, Simpson D,
Vehtari A, Betancourt M, Gelman A (2019). “Visualization in Bayesian
workflow.” J. R. Stat. Soc. A, 182, 389-402. doi:10.1111/rssa.12378 https://doi.org/10.1111/rssa.12378.
- Grolemund G, Wickham H (2011). “Dates and Times Made Easy with
lubridate.” Journal of Statistical Software, 40(3),
1-25. https://www.jstatsoft.org/v40/i03/.
- Hester J, Wickham H, Csárdi G (2024). fs: Cross-Platform File
System Operations Based on ‘libuv’. R package version 1.6.4, https://CRAN.R-project.org/package=fs.
- Küng P (2023). wbCorr: Bivariate Within- and Between-Cluster
Correlations. University of Zürich. R package version 0.1.22. https://github.com/Pascal-Kueng/wbCorr.
- Müller K, Wickham H (2023). tibble: Simple Data Frames. R
package version 3.2.1, https://CRAN.R-project.org/package=tibble.
- R Core Team (2023). R: A Language and Environment for
Statistical Computing. R Foundation for Statistical Computing,
Vienna, Austria. https://www.R-project.org/.
- Schauberger P, Walker A (2023). openxlsx: Read, Write and Edit
xlsx Files. R package version 4.2.5.2, https://CRAN.R-project.org/package=openxlsx.
- Wickham H (2016). ggplot2: Elegant Graphics for Data
Analysis. Springer-Verlag New York. ISBN 978-3-319-24277-4, https://ggplot2.tidyverse.org.
- Wickham H (2023). forcats: Tools for Working with Categorical
Variables (Factors). R package version 1.0.0, https://CRAN.R-project.org/package=forcats.
- Wickham H (2023). stringr: Simple, Consistent Wrappers for
Common String Operations. R package version 1.5.1, https://CRAN.R-project.org/package=stringr.
- Wickham H (2024). rvest: Easily Harvest (Scrape) Web Pages.
R package version 1.0.4, https://CRAN.R-project.org/package=rvest.
- Wickham H, Averick M, Bryan J, Chang W, McGowan LD, François R,
Grolemund G, Hayes A, Henry L, Hester J, Kuhn M, Pedersen TL, Miller E,
Bache SM, Müller K, Ooms J, Robinson D, Seidel DP, Spinu V, Takahashi K,
Vaughan D, Wilke C, Woo K, Yutani H (2019). “Welcome to the tidyverse.”
Journal of Open Source Software, 4(43), 1686. doi:10.21105/joss.01686
https://doi.org/10.21105/joss.01686.
- Wickham H, Bryan J (2023). readxl: Read Excel Files. R
package version 1.4.3, https://CRAN.R-project.org/package=readxl.
- Wickham H, François R, Henry L, Müller K, Vaughan D (2023).
dplyr: A Grammar of Data Manipulation. R package version 1.1.4,
https://CRAN.R-project.org/package=dplyr.
- Wickham H, Henry L (2023). purrr: Functional Programming
Tools. R package version 1.0.2, https://CRAN.R-project.org/package=purrr.
- Wickham H, Hester J, Bryan J (2024). readr: Read Rectangular
Text Data. R package version 2.1.5, https://CRAN.R-project.org/package=readr.
- Wickham H, Hester J, Ooms J (2023). xml2: Parse XML. R
package version 1.3.6, https://CRAN.R-project.org/package=xml2.
- Wickham H, Vaughan D, Girlich M (2024). tidyr: Tidy Messy
Data. R package version 1.3.1, https://CRAN.R-project.org/package=tidyr.
- Xie Y (2024). knitr: A General-Purpose Package for Dynamic
Report Generation in R. R package version 1.46, https://yihui.org/knitr/. Xie Y (2015). Dynamic
Documents with R and knitr, 2nd edition. Chapman and Hall/CRC, Boca
Raton, Florida. ISBN 978-1498716963, https://yihui.org/knitr/. Xie Y (2014). “knitr: A
Comprehensive Tool for Reproducible Research in R.” In Stodden V, Leisch
F, Peng RD (eds.), Implementing Reproducible Computational
Research. Chapman and Hall/CRC. ISBN 978-1466561595.
- Zhu H (2024). kableExtra: Construct Complex Table with ‘kable’
and Pipe Syntax. R package version 1.4.0, https://CRAN.R-project.org/package=kableExtra.